package tq.com.tqcom.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.githang.statusbar.StatusBarCompat;

import tq.com.tqcom.R;
import tq.com.tqcom.view.TQHeader5View;


public class BaseTitleActivity extends BaseActivity {
    protected TQHeader5View mHeader5View;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_basetitle_layout);
        setStatusBar();

        mHeader5View = findViewById(R.id.title);
        initHeader(mHeader5View);

        if(fragment() != null){
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.content, fragment())
                    .commit();
        }


    }


    protected BaseFragment fragment(){
        return null;
    }

    protected void initHeader(TQHeader5View pHeader5View){
        pHeader5View.getTitleView().setText(getTitle());

        pHeader5View.getBackIcon().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BaseTitleActivity.this.finish();
            }
        });

        StatusBarCompat.setLightStatusBar(getWindow(), true);
    }
    public void setHeaderTitle(String t){
        mHeader5View.getTitleView().setText(t);
    }
}
